{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "2102d381",
   "metadata": {},
   "outputs": [],
   "source": [
    "import logging\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "1095e11a",
   "metadata": {},
   "outputs": [],
   "source": [
    "logging.basicConfig(level=logging.WARNING,\n",
    "                   filename=r'E:\\pycharm_out\\yufa\\git_test\\报错.txt',\n",
    "                   filemode = 'w',\n",
    "                   format='%(asctime)s - %(filename)s[line:%(lineno)d] - %(levelname)s: %(message)s')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "714da345",
   "metadata": {},
   "outputs": [],
   "source": [
    "a = 1\n",
    "b = 0\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "cea9297a",
   "metadata": {},
   "outputs": [],
   "source": [
    "try:\n",
    "    c = a / b\n",
    "except Exception as ERR:\n",
    "    logging.error('出错了 {}'.format(ERR))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a573ce31",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
